layui.use('layer', function(){ //独立版的layer无需执行这一句
    var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
});

var layer = layui.layer //弹层
    ,laypage = layui.laypage //分页
    ,laydate = layui.laydate //日期
    ,table = layui.table //表格
    ,carousel = layui.carousel //轮播
    ,upload = layui.upload //上传
    ,element = layui.element //元素操作
    ,slider = layui.slider //滑块
    ,dropdown = layui.dropdown //下拉菜单
//执行一个轮播实例
carousel.render({
    elem: '#test1'
    ,width: '100%' //设置容器宽度
    ,height: 600
    ,arrow: 'none' //不显示箭头
    ,anim: 'fade' //切换动画方式
});


layui.use('element', function () {
    var element = layui.element;
});

//将日期直接嵌套在指定容器中
var dateIns = laydate.render({
    elem: '#laydateDemo'
    ,position: 'static'
    ,calendar: true //是否开启公历重要节日
    ,mark: { //标记重要日子
        '0-10-14': '生日'
        ,'2020-01-18': '小年'
        ,'2020-01-24': '除夕'
        ,'2020-01-25': '春节'
        ,'2020-02-01': '上班'
    }
    ,done: function(value, date, endDate){
        if(date.year == 2017 && date.month == 11 && date.date == 30){
            dateIns.hint('一不小心就月底了呢');
        }
    }
    ,change: function(value, date, endDate){
        layer.msg(value)
    }
});

//分页
laypage.render({
    elem: 'pageDemo' //分页容器的id
    ,count: 1000 //数据总数
    ,limit: 10 //每页显示的数据条数
    ,skin: '#1E9FFF' //自定义选中色值
    //,layout: ['prev', 'page', 'next', 'count', 'limit', 'refresh', 'skip'] //自定义排版
    ,jump: function(obj, first){
        if(!first){
            layer.msg('第'+ obj.curr +'页', {offset: 'b'});
        }
    }
});



//上传
upload.render({
    elem: '#uploadDemo'
    ,url: 'https://httpbin.org/post' //改成您自己的上传接口
    ,done: function(res){
        layer.msg('上传成功');
        layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', res.files.file);
        console.log(res)
    }
    ,before: function(){
        layer.msg('上传中', {icon: 16, time: 0});
    }
});

//滑块
var sliderInst = slider.render({
    elem: '#sliderDemo'
    ,input: true //输入框
});
